package cn.net.shuxing.yifu.common.service;

import cn.net.shuxing.yifu.common.bean.Permission;
import cn.net.shuxing.yifu.common.bean.PermissionGroup;
import cn.net.shuxing.yifu.common.mapper.PermissionMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class PermissionService extends BaseService<Permission,PermissionMapper>{


    @Autowired
    private PermissionGroupService permissionGroupService;


    public PermissionService insertPermission(String permissionName, int permissionGroupId)
    {
        Permission permission = new Permission();
        permission.setName(permissionName);
        permission.setPermissionGroupId(permissionGroupId);

        mapper.insertSelective(permission);
        return this;
    }

    public List<PermissionGroup> getAllPermisionWithGroup()
    {
        return permissionGroupService.getAll();
    }
}
